home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
dev
/
gcc
/
ixemul_src.lha
/
ixemul-41.0
/
man
/
cat2
/
execve.0
< prev
next >
Wrap
Text File
|
1992-08-10
|
8KB
|
199 lines
EXECVE(2) UNIX Programmer's Manual EXECVE(2)
NNAAMMEE
eexxeeccvvee - execute a file
SSYYNNOOPPSSIISS
##iinncclluuddee <<uunniissttdd..hh>>
_i_n_t
eexxeeccvvee(_c_o_n_s_t _c_h_a_r _*_p_a_t_h, _c_o_n_s_t _* _c_h_a_r _*_a_r_g_v, _c_o_n_s_t _* _c_h_a_r _*_e_n_v_p)
DDEESSCCRRIIPPTTIIOONN
EExxeeccvvee() transforms the calling process into a new process. The new pro
cess is constructed from an ordinary file, whose name is pointed to by
_p_a_t_h, called the _n_e_w _p_r_o_c_e_s_s _f_i_l_e. This file is either an executable ob
ject file, or a file of data for an interpreter. An executable object
file consists of an identifying header, followed by pages of data repre
senting the initial program (text) and initialized data pages. Addition
al pages may be specified by the header to be initialized with zero data;
see a.out(5).
An interpreter file begins with a line of the form:
##!! _i_n_t_e_r_p_r_e_t_e_r [_a_r_g]
When an interpreter file is eexxeeccvvee()'d, the system eexxeeccvvee()'s the speci
fied _i_n_t_e_r_p_r_e_t_e_r. If the optional _a_r_g is specified, it becomes the first
argument to the _i_n_t_e_r_p_r_e_t_e_r, and the name of the originally eexxeeccvvee()'d
file becomes the second argument; otherwise, the name of the originally
eexxeeccvvee()'d file becomes the first argument. The original arguments are
shifted over to become the subsequent arguments. The zeroth argument,
normally the name of the eexxeeccvvee()'d file, is left unchanged.
The argument _a_r_g_v is a pointer to a nullterminated array of character
pointers to nullterminated character strings. These strings construct
the argument list to be made available to the new process. At least one
argument must be present in the array; by custom, the first element
should be the name of the executed program (for example, the last compo
nent of _p_a_t_h).
The argument _e_n_v_p is also a pointer to a nullterminated array of charac
ter pointers to nullterminated strings. A pointer to this array is nor
mally stored in the global variable _e_n_v_i_r_o_n_. These strings pass informa
tion to the new process that is not directly an argument to the command
(see environ(7)).
File descriptors open in the calling process image remain open in the new
process image, except for those for which the closeonexec flag is set
(see close(2) and fcntl(2)). Descriptors that remain open are unaffected
by eexxeeccvvee().
Signals set to be ignored in the calling process are set to be ignored in
the new process. Signals which are set to be caught in the calling pro
cess image are set to default action in the new process image. Blocked
signals remain blocked regardless of changes to the signal action. The
signal stack is reset to be undefined (see sigaction(2) for more informa
tion).
If the setuserID mode bit of the new process image file is set (see
chmod(2)), the effective user ID of the new process image is set to the
owner ID of the new process image file. If the setgroupID mode bit of
the new process image file is set, the effective group ID of the new pro
cess image is set to the group ID of the new process image file. The re
al user ID, real group ID and supplementary group IDs of the new process
image remain the same as the calling process image.
The new process also inherits the following attributes from the calling
process:
process ID see getpid(2)
parent process ID see getppid(2)
process group ID see getpgrp(2)
access groups see getgroups(2)
working directory see chdir(2)
root directory see chroot(2)
control terminal see termios(4)
resource usages see getrusage(2)
interval timers see getitimer(2)
resource limits see getrlimit(2)
file mode mask see umask(2)
signal mask see sigvec(2), sigsetmask(2)
When a program is executed as a result of an eexxeeccvvee() call, it is entered
as follows:
main(argc, argv, envp)
int argc;
char **argv, **envp;
where _a_r_g_c is the number of elements in _a_r_g_v (the ``arg count'') and _a_r_g_v
points to the array of character pointers to the arguments themselves.
RREETTUURRNN VVAALLUUEESS
As the eexxeeccvvee() function overlays the current process image with a new
process image the successful call has no process to return to. If
eexxeeccvvee() does return to the calling process an error has occurred; the
return value will be 1 and the global variable _e_r_r_n_o is set to indicate
the error.
EERRRROORRSS
EExxeeccvvee() will fail and return to the calling process if:
[ENOTDIR] A component of the path prefix is not a directory.
[EINVAL] The pathname contains a character with the highorder bit
set.
[ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
entire path name exceeded 1023 characters.
[ENOENT] The new process file does not exist.
[ELOOP] Too many symbolic links were encountered in translating
the pathname.
[EACCES] Search permission is denied for a component of the path
prefix.
[EACCES] The new process file is not an ordinary file.
[EACCES] The new process file mode denies execute permission.
[ENOEXEC] The new process file has the appropriate access permis
sion, but has an invalid magic number in its header.
[ETXTBSY] The new process file is a pure procedure (shared text)
file that is currently open for writing or reading by
some process.
[ENOMEM] The new process requires more virtual memory than is al
lowed by the imposed maximum (getrlimit(2)).
[E2BIG] The number of bytes in the new process's argument list is
larger than the systemimposed limit. The limit in the
system as released is 20480 bytes (NCARGS in
<_s_y_s_/_p_a_r_a_m_._h>.
[EFAULT] The new process file is not as long as indicated by the
size values in its header.
[EFAULT] _P_a_t_h, _a_r_g_v, or _e_n_v_p point to an illegal address.
[EIO] An I/O error occurred while reading from the file system.
CCAAVVEEAATT
If a program is _s_e_t_u_i_d to a nonsuperuser, but is executed when the real
_u_i_d is ``root'', then the program has some of the powers of a superuser
as well.
SSEEEE AALLSSOO
exit(2), fork(2), execl(3), environ(7)
HHIISSTTOORRYY
The eexxeeccvvee function call appeared in 4.2BSD.
4th Berkeley Distribution March 10, 1991 3